﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Web.UI;


namespace Gift.Utile
{
    public static class Message
    {
        public static void Msg(Page page, string content, MessageType type)
        {
            Msg(page, content, 1500, type);
        }

        public static void Msg(Page page, string content, int time, MessageType type)
        {
            page.ClientScript.RegisterStartupScript(page.GetType(), "",
                "$(document).ready(function() { $.systemalt('" + content + "'," + time + ",'" + type.ToString() + "');});", true);
        }

        #region JavaScript辅助方法
        public static string WrapJavaScript(string content)
        {
            StringBuilder result = new StringBuilder();
            result.Append("<script language='javascript' type='text/javascript'>");
            result.Append(content);
            result.Append("</script>");
            return result.ToString();
        }
        #endregion
    }

    public enum MessageType
    {
        Normal = 1,
        Success = 2,
        Failure = 3
    }
}
